Vim 的各种插件安装

安装 vim 最新版

1
brew install vim

安装 ctags

1
brew install ctags

MacOS 可能会在运行 ctags –version 的时候报错, 添加

1
alias ctags="`brew --prefix`/bin/ctags"

~/.bashrc 或者 ~/.zshrc.

环境准备

插件存储目录

1
mkdir -p ~/.vim/autoload ~/.vim/bundle

vim 配置文件

1
touch ~/.vimrc

下载插件

1
2
3
4
5
6
7
8
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

cd ~/.vim/bundle/
git clone https://github.com/plasticboy/vim-markdown.git
git clone https://github.com/fatih/vim-go.git
git clone https://github.com/Blackrush/vim-gocode.git
git clone https://github.com/majutsushi/tagbar.git
git clone https://github.com/vim-syntastic/syntastic.git

配置插件

编辑 ~/.vimrc 文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
execute pathogen#infect()
filetype plugin indent on

set nu
set cursorline
syntax on
set ruler
set nocompatible
set backspace=indent,eol,start
set shiftwidth=2
set softtabstop=2
set ts=4
set expandtab
set hlsearch

set omnifunc=syntaxcomplete#Complete
imap <F5> <C-x><C-o>
nmap <F8> :TagbarToggle<CR>

set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_go_checkers = ['gofmt', 'golint']

下载基础支持软件

安装 keyify

进入 $GOPATH/src 目录

1
2
3
4
5
mkdir -p honnef.co/go/tools
git clone https://github.com/dominikh/go-tools honnef.co/go/tools

cd honnef.co/go/tools/cmd/keyify && go build
mv keyify $GOBIN

安装 gocode

1
go get github.com/nsf/gocode

一键安装辅助工具

执行 vim 命令, 进入 vim, 执行 :GoInstallBinaries 安装全家桶工具.

可能过程中需要科学上网, 也可以手动安装下面的内容, 然后将其存放到 $PATH 路径下(例如 /usr/local/bin/)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
go get golang.org/x/tools/cmd/guru
go get golang.org/x/tools/cmd/goimports
go get golang.org/x/tools/cmd/gorename
go get github.com/zmb3/gogetdoc
go get github.com/golang/lint/golint
go get github.com/davidrjenni/reftools/cmd/fillstruct
go get github.com/rogpeppe/godef
go get github.com/fatih/motion
go get github.com/kisielk/errcheck
go get github.com/nsf/gocode
go get github.com/jstemmer/gotags
go get github.com/josharian/impl
go get github.com/fatih/gomodifytags
go get github.com/dominikh/go-tools/cmd/keyify
go get github.com/klauspost/asmfmt/cmd/asmfmt
go get github.com/alecthomas/gometalinter
Donate - Support to make this site better.
捐助 - 支持我让我做得更好.